package com.rybbaby.tss.platform.websocket.config;

import com.rybbaby.tss.platform.websocket.handler.MsgWebSocketHandler;
import com.rybbaby.tss.platform.websocket.handshake.MsgHandShake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @description WebScoket配置处理器
 * 
 * @author 谢进伟
 * 
 * @createDate 2017-02-13 下午12:30:40
 */
@Component
@EnableWebSocket
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
	
	@Autowired
	MsgWebSocketHandler handler;
	
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		registry.addHandler(handler , "/ws/talk").addInterceptors(new MsgHandShake());
		registry.addHandler(handler , "/ws/talk/sockjs").addInterceptors(new MsgHandShake()).withSockJS();
	}
	
}
